package script

import (
	"gitee.com/fierce_wolf/go-fox-edge-common/edgeEntity"
	"github.com/dop251/goja"
)

var (
	service *scriptEngineService
)

func init() {
	service = &scriptEngineService{}
}

func GetScriptEngine(manufacturer string, deviceType string, operateName string) *goja.Runtime {
	return service.getScriptEngine(manufacturer, deviceType, operateName)
}

func GetSplitOperate(channelParam map[string]interface{}) (*edgeEntity.OperateEntity, error) {
	return service.getSplitOperate(channelParam)
}

func GetKeyOperate(channelParam map[string]interface{}) (*edgeEntity.OperateEntity, error) {
	return service.getKeyOperate(channelParam)
}

func BuildSplitOperate(operateEntity *edgeEntity.OperateEntity) (dec *Decoder, err error) {
	return service.buildSplitOperate(operateEntity)
}

func BuildServiceKeyOperate(operateEntity *edgeEntity.OperateEntity) (dec *Decoder, err error) {
	return service.buildServiceKeyOperate(operateEntity)
}
